﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Xceed.Silverlight.Data
{
  internal sealed class DataSourceWrapperDataHelper : IDataSourceWrapperHelper
  {
    #region Constructor

    internal DataSourceWrapperDataHelper( IDataHelper childDataHelper )
    {
      if( childDataHelper == null )
        throw new ArgumentNullException( "childDataHelper" );

      m_childDataHelper = childDataHelper;
    }

    #endregion

    #region IDataSourceWrapperHelper Members

    public DataPath Convert( object item )
    {
      return m_childDataHelper.DeepConvert( item );
    }

    public object ConvertBack( DataPath path )
    {
      return m_childDataHelper.DeepConvertBack( path );
    }

    public IEnumerable<SortDescription> GetCurrentCompleteSortOrder()
    {
      return m_childDataHelper.GetCurrentCompleteSortOrder();
    }

    #endregion

    #region IItemHelper Members

    public object GetMemberValue( string propertyPath, DataPath path )
    {
      return m_childDataHelper.GetMemberValue( propertyPath, path );
    }

    public bool TryGetMemberValue( string propertyPath, DataPath path, out object value )
    {
      return m_childDataHelper.TryGetMemberValue( propertyPath, path, out value );
    }

    #endregion

    #region IGroupHelper Members

    public bool IsGroupPath( DataPath item )
    {
      return m_childDataHelper.IsGroupPath( item );
    }

    public DataPath GetGroupPath( DataPath item )
    {
      return m_childDataHelper.GetGroupPath( item );
    }

    public SortPosition CreateSortPosition( DataPath item, StartPosition startPosition )
    {
      return m_childDataHelper.CreateSortPosition( item, startPosition );
    }

    #endregion

    #region ICompareHelper Members

    public int Compare( DataPath firstItem, DataPath secondItem )
    {
      return m_childDataHelper.Compare( firstItem, secondItem );
    }

    public int Compare( DataPath item, SourcePosition position )
    {
      return m_childDataHelper.Compare( item, position );
    }

    public int Compare( SourcePosition position, DataPath item )
    {
      return m_childDataHelper.Compare( position, item );
    }

    public int Compare( SourcePosition firstPosition, SourcePosition secondPosition )
    {
      return m_childDataHelper.Compare( firstPosition, secondPosition );
    }

    public int Compare( IList<SortDescription> sortDescriptions, DataPath firstItem, DataPath secondItem )
    {
      return m_childDataHelper.Compare( sortDescriptions, firstItem, secondItem );
    }

    public int Compare( string propertyPath, object firstValue, object secondValue )
    {
      return m_childDataHelper.Compare( propertyPath, firstValue, secondValue );
    }

    #endregion

    #region IEditHelper Members

    public void Invalidate( DataPath item )
    {
      m_childDataHelper.Invalidate( item );
    }

    #endregion

    #region Private Fields

    private readonly IDataHelper m_childDataHelper;

    #endregion
  }
}
